# import asyncio
#
# from src.common.mem_data import MemData
# from src.common.prj_path import get_abs_path
# from src.fsm_state.run import RunFsm
# from src.workflow.auto_login import AutoLogin
# from src.workflow.goto_business import GotoBusiness
# from src.workflow.open_browser import OpenBrowser
# from src.workflow.open_page import OpenPage
# from src.workflow.close_browser import CloseBrowser
#
# WorkFlowDict = {
#     'open_browser': OpenBrowser,
#     'open_page': OpenPage,
#     'auto_login': AutoLogin,
#     'goto_business': GotoBusiness,
#     'close_browser': CloseBrowser,
# }
#
#
# class WorkThread(object):
#     def __init__(self):
#         # self.task_to_do = MemData.workflow
#         self.task_to_do = WorkFlowDict
#
#     async def run_workflow(self):
#         for task in self.task_to_do:
#             step_object = WorkFlowDict[task]()
#             await step_object.run()
#
#
# def start_work_thread():
#     work_thread = WorkThread()
#     asyncio.run(work_thread.run_workflow())


import logging.config

from src.android.adb.drive import ADB
from src.android.uiauto.drive import UIAutoControlClass
from src.business.qian_niu import QianNiuApp
from src.common.mem_data import MemData
from src.common.prj_path import get_abs_path
from src.common.read_ini import read_ini
from src.transition.test import TransitionFsm


def prepare():
    log_conf = get_abs_path('settings', 'logging.conf')
    privacy_conf = get_abs_path('privacy', 'settings.ini')
    logging.config.fileConfig(log_conf)
    MemData.config = read_ini(privacy_conf)


if __name__ == '__main__':
    prepare()
    UI = UIAutoControlClass('192.168.2.243')
    path = get_abs_path('scripts', 'qian_niu.yaml')
    send = QianNiuApp()
    adb = ADB()

    parse_object = [UI, send, adb]
    a = TransitionFsm(parse_object)
    a.run()
